﻿using System;
using System.Runtime.Serialization;

namespace SSTestAPI
{
    [Serializable]
    public class Tree : Plant, ISerializable
    {
        public string Group { get; set; }

        public bool Fruit { get; set; }

        public Tree() : base()
        {
            Fruit = false;
            Group = null;
        }

        public Tree(string branch, string group, bool fruit, int life)
            : base(branch, life)
        {
            Fruit = fruit;
            Group = group;
        }

        public override int getLifetime()
        {
            return lifetime;
        }

        protected Tree(SerializationInfo info, StreamingContext ctxt)
		{
            branch = info.GetString("PlantBranch");
            lifetime = info.GetInt32("PlantLifetime");
            Group = info.GetString("TreeGroup");
            Fruit = info.GetBoolean("TreeFruit");
		} 

        public virtual void GetObjectData(SerializationInfo info, StreamingContext ctxt)
        {
            info.AddValue("PlantBranch", branch);
            info.AddValue("PlantLifetime", lifetime);
            info.AddValue("TreeGroup", Group);
            info.AddValue("TreeFruit", Fruit);
        }
    }
}
